package cn.xttc.edu.util;

import com.soecode.wxtools.api.IService;
import com.soecode.wxtools.api.WxConsts;
import com.soecode.wxtools.api.WxService;
import com.soecode.wxtools.bean.WxMenu;
import com.soecode.wxtools.exception.WxErrorException;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 生成微信公众号菜单
 * @author yl
 */
public class WxAccountMenu {
    public static void main(String[] args) {
        IService iService = new WxService();
        WxMenu menu = new WxMenu();
        List<WxMenu.WxMenuButton> btnList = new ArrayList<>();
        //飙升功能
        WxMenu.WxMenuButton btn1 = new WxMenu.WxMenuButton();
        btn1.setName("客户业务");
        btn1.setType(WxConsts.MENU_BUTTON_VIEW);
        btn1.setUrl("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx0592a476cf49a60c&redirect_uri=http://50er112323.zicp.vip/wx/customer&response_type=code&scope=snsapi_base&state=123#wechat_redirect");

        WxMenu.WxMenuButton btn2 = new WxMenu.WxMenuButton();
        btn2.setType(WxConsts.MENU_BUTTON_VIEW);
        btn2.setUrl("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx0592a476cf49a60c&redirect_uri=http://50er112323.zicp.vip/wx/driver&response_type=code&scope=snsapi_base&state=123#wechat_redirect");
        btn2.setName("司机业务");

        //将三个按钮设置进btnList
        btnList.add(btn1);
        btnList.add(btn2);
        //设置进菜单类
        menu.setButton(btnList);
        //调用API即可
        try {
            //参数1--menu  ，参数2--是否是个性化定制。如果是个性化菜单栏，需要设置MenuRule
            iService.createMenu(menu, false);
        } catch (WxErrorException e) {
            e.printStackTrace();
        }
    }
}
